package com.atguigu.staservice.schedule;

import com.atguigu.staservice.service.StatisticsDailyService;
import com.atguigu.staservice.utils.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
public class SchedeledTask {
    @Autowired
    private StatisticsDailyService statisticsDailyService;
//    //每个五秒执行一次的方法
//    @Scheduled(cron = "0/5 * * * * ?")
//    public void task1(){
//        System.out.println("******task1执行");
//
//    }
    //每天执行方法
//    @Scheduled(cron = "0/5 * * * * ?")
    public void task2(){
//        System.out.println("******task1执行");
        statisticsDailyService.registerCount(DateUtil.formatDate(DateUtil.addDays(new Date(),-1)));
    }


}
